########################################################################
# gmould.sh - GMOULD shell functions library
# Copyright (C) 2013 Mohamad Afifi Omar <afifio@gmail.com>
#
# These comments cannot be remove or edited and should remain intact
# because this file comments is an extension to the GPL3 license.
# This software file is covered by GPL version 3 license.
# Please see the LICENSE and gpl3.txt or gpl3.htm in doc directory
# for the license agreement, if its not exist, write to the 
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Modification below this line is allowed
########################################################################
# Extra credits to:
#
########################################################################
# Notes:
# Put notes to other future developer/contributor here

# App have many Functions
# App have many Dialog
# Dialog have many Component+(Layout)
# Component have many Widget+(Layout)
# Dialog preferably run as another gtkdialog process to avoid
# crashing the main App
#
# progname.registry.sh 	- Component/Widget App specific configuration
# progname.function.sh 	- script functions and your script
# progname.dialog.sh 	- contain dialogs and its defaults
# progname.component.sh - contain components and its defaults
#
# Warning:
# Since everything got dumped into environment, strongly named
# function and variable must be used to avoid collision/poisoning
# for example avoid using EDITOR but use MYSUPERMAGICEDITOR instead.
########################################################################
# call the supporting libs

source $PROGLIB/constant.sh
source $PROGLIB/snippets.sh
source $PROGLIB/gmould.res
source $PROGLIB/gmould.registry.sh
source $PROGLIB/gmould.function.sh
source $PROGLIB/gmould.component.sh
source $PROGLIB/gmould.dialog.sh
########################################################################
# gMouldToolButton - The widgets toolbutton
# Usage: gMouldToolButton param1 tooltip param3
########################################################################
gMouldToolButton()
{
#	ToolboxButton param1 tooltip param3  			# call in script
#   '"$(ToolboxButton param1 tooltip param3)"' 		# call in xml

echo '
<button tooltip-text=" '$2' ">
	<input file>"'$PROGPIX'/images/'$1'.png"</input>
	<action>'$3' $ACTIVEFILE</action>
	<action signal="clicked">refresh:ACTIVEEDITOR</action>
</button>
'
};export -f gMouldToolButton




function gButton()
{
	btnattribute=(space-expand space-fill)
	btnattrvalue=(true false)
	btncontents="Hello world"
	btn=( parent vbox ${btnattribute} ${btnattrvalue} "Hello world" )


	echo '------------'
	attrname=`echo ${btnattribute[*]}`
	attrvalue=`echo ${btnattrvalue[*]}`
	attr=`MakeAttribute "$attrname" "$attrvalue"`
	#MakeAttribute $btnattribute $btnattrvalue 
	 
	echo '<'${btn[1]} ${attr}'>'
	echo "${btn[4]}"
	echo '</'${btn[1]}'>'
	echo '------------'
}
MakeAttribute()
{
	local name   # Local variable.
	local value  # Local variable.
	name=( `echo "$1"` )
	value=( `echo "$2"` )
	LIMIT=${#name[@]}
	for ((index=0; index < LIMIT ; index++))  
	do
		#eval "$result"=\'"${name[$index]}${value[$index]}"\'
		#eval $result=${name[$index]}=${value[$index]}
		#$result=$result' '${name[$index]}'="'${value[$index]}'"'
		echo -n ' '${name[$index]}'="'${value[$index]}'"'
	done
}
export -f MakeAttribute
export -f gButton




